package com.jiemengshi.server.mapper;

import com.jiemengshi.server.model.DreamRecord;
import com.jiemengshi.server.model.DreamRecordUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public interface DreamRecordMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(DreamRecord record);

    int insertSelective(DreamRecord record);

    DreamRecord selectByPrimaryKey(Integer id);

    List<DreamRecord> selectByUserId(@Param("wechatUserId") int wechatUserId, @Param("start") int start, @Param("limit") int limit);

    List<DreamRecord> selectByTitle(@Param("wechatUserId") int wechatUserId, @Param("title") String title, @Param("start") int start, @Param("limit") int limit);

    int countByUserId(int wechatUserId);
    
    int countByTitle(@Param("wechatUserId") int wechatUserId, @Param("title") String title);

    List<DreamRecordUser> listByTime(@Param("start") int start, @Param("limit") int limit);

    int countByTime();

    int countByUser();

    int countByNickname(String nickname);

    int countVoiceByTime(@Param("wechatUserId") int wechatUserId, @Param("startTime") String startTime, @Param("endTime") String endTime);
    
    List<DreamRecordUser> listByUser(@Param("start") int start, @Param("limit") int limit);

    List<DreamRecordUser> searchByNickname(@Param("nickname") String nickname, @Param("start") int start, @Param("limit") int limit);
    
    int updateByPrimaryKeySelective(DreamRecord record);

    int updateByPrimaryKey(DreamRecord record);

    int updateNewReply(@Param("id") int id, @Param("newReply") int newReply);
    
    int updateUserReply(@Param("id") int id, @Param("userReply") int userReply);

    int updateNeedHelp(@Param("id") int id, @Param("needHelp") int needHelp);
}